import { Modal } from 'antd'
import React from 'react'

interface MessageBoxProps {
    message: string
    onResult: (result: boolean) => void
}

const MessageBox: React.FC<MessageBoxProps> = ({ message, onResult }) => {
    React.useEffect(() => {
        const modal = Modal.confirm({
            title: '提示',
            content: message,
            okText: '确定',
            cancelText: '取消',
            onOk: () => onResult(true),
            onCancel: () => onResult(false),
        })
        return () => {
            modal.destroy()
        }
    }, [message, onResult])
    return null
}

export default MessageBox
